package cn.edu.scau.cmi.front.service;

import java.util.Set;

import javax.annotation.PostConstruct;

import org.springframework.stereotype.Service;

import cn.edu.scau.cmi.ema.service.base.CmiEmaService;
//杨宏宇同学编写，2021-0514
//好像没用到
//@PropertySource("classpath:ema-foodtype.properties") 

@Service
public class CmiFoodTypeIdService extends CmiEmaService {

	@PostConstruct
	public void print() {
//		System.out.println("agriculturalProductIdSet : " + agriculturalProductIdSet);
//		System.out.println("grainAndOilIdSet : " + grainAndOilIdSet);
//		System.out.println("meatIdSet : " + meatIdSet);
//		System.out.println("aquaticIdSet : " + aquaticIdSet);
//		System.out.println("milkIdSet : " + milkIdSet);
//		System.out.println("otherIdSet : " + otherIdSet);
//		System.out.println("processedIdSet : " + processedIdSet);
	}

	public boolean isAgriculturalProduct(int foodtypeId) {
		return agriculturalProductIdSet.contains(foodtypeId);
	}

	public boolean isGrainAndOil(int foodtypeId) {
		return grainAndOilIdSet.contains(foodtypeId);
	}

	public boolean isMeat(int foodtypeId) {
		return meatIdSet.contains(foodtypeId);
	}

	public boolean isAquatic(int foodtypeId) {
		return aquaticIdSet.contains(foodtypeId);
	}

	public boolean isMilk(int foodtypeId) {
		return milkIdSet.contains(foodtypeId);
	}

	public boolean isOther(int foodtypeId) {
		return otherIdSet.contains(foodtypeId);
	}

	public boolean isProcessed(int foodtypeId) {
		return processedIdSet.contains(foodtypeId);
	}

	public Set<Integer> getMeatIdSet() {
		return meatIdSet;
	}

	public Set<Integer> getAquaticIdSet() {
		return aquaticIdSet;
	}

	public Set<Integer> getMilkIdSet() {
		return milkIdSet;
	}

	public Set<Integer> getOtherIdSet() {
		return otherIdSet;
	}

	public Set<Integer> getAgriculturalProductIdSet() {
		return agriculturalProductIdSet;
	}

	public Set<Integer> getGrainAndOilIdSet() {
		return grainAndOilIdSet;
	}

	public Set<Integer> getProcessedIdSet() {
		return processedIdSet;
	}

	public Set<Integer> getFoodtypeIdSetByFoodtypeId(int foodtypeId) {
		Set<Integer> foodtypeIdSet = null;
		
		if (isAgriculturalProduct(foodtypeId)) {
			foodtypeIdSet = getAgriculturalProductIdSet();
		} else if (isAquatic(foodtypeId)) {
			foodtypeIdSet = getAquaticIdSet();
		} else if (isGrainAndOil(foodtypeId)) {
			foodtypeIdSet = getGrainAndOilIdSet();
		} else if (isMeat(foodtypeId)) {
			foodtypeIdSet = getMeatIdSet();
		} else if (isMilk(foodtypeId)) {
			foodtypeIdSet = getMilkIdSet();
		} else if (isOther(foodtypeId)) {
			foodtypeIdSet = getOtherIdSet();
		} else if (isProcessed(foodtypeId)) {
			foodtypeIdSet = getProcessedIdSet();
		} else {
		}
		return foodtypeIdSet;
	}
	
	public String getFoodtypeNameByFoodtypeId(int foodtypeId) {
		String foodtypeName = null;

		if (isAgriculturalProduct(foodtypeId)) {
			foodtypeName = "农产品";
		} else if (isAquatic(foodtypeId)) {
			foodtypeName = "水产品";
		} else if (isGrainAndOil(foodtypeId)) {
			foodtypeName = "粮油品";
		} else if (isMeat(foodtypeId)) {
			foodtypeName = "肉制品";
		} else if (isMilk(foodtypeId)) {
			foodtypeName = "乳制品";
		} else if (isOther(foodtypeId)) {
			foodtypeName = "其他制品";
		}
		else if (isProcessed(foodtypeId)) {
			foodtypeName = "加工类食品";
		}else {
			foodtypeName = "所有食品";
		}
		return foodtypeName;
	}
}
